﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/Admin.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="Admin_Modules_Categories_Default" %>

<%@ Register TagPrefix="avg" Namespace="Avg.Controls" Assembly="SmartPager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="c" runat="Server">
    <script src="/Admin/Modules/Categories/js/categoryedit.js" type="text/javascript"></script>
    <input type="hidden" id="hdfTaxonomy" value="category" />
    <div id="wpbody-content">
        <div class="wrap nosubsub">
            <div>
                <div id="icon-edit" class="icon32">
                    <br />
                </div>
                <h2>
                    Categories</h2>
                <%-- <div id="message" class="updated below-h2">
                    <p>
                        Item updated.
                    </p>
                </div>
                <div id="ajax-response">
                    <div class="error">
                        <p>
                            A term with the name provided already exists with this parent.
                        </p>
                    </div>
                </div>--%>
                <p class="search-box">
                    <label class="screen-reader-text" for="tag-search-input">
                        Search Categories:</label>
                    <input type="text" id="tag-search-input" name="s" value="">
                    <input type="submit" name="" id="search-submit" class="button" value="Search Categories">
                </p>
                <br class="clear" />
            </div>
            <div id="col-container">
                <div id="col-right">
                    <div class="col-wrap">
                        <div>
                            <div class="tablenav top">
                                <div class="alignleft actions">
                                    <select name="action">
                                        <option value="-1" selected="selected">Bulk Actions</option>
                                        <option value="delete">Delete</option>
                                    </select>
                                    <input type="button" name="" id="doaction" class="button-secondary action" value="Apply" />
                                </div>
                                <div class="tablenav-pages">
                                    <avg:SmartPager ID="smartPager" runat="server" Visible="false" />
                                    <%--  <span class="displaying-num">62 items</span> <span class="pagination-links"><a class="first-page disabled"
                                        title="Go to the first page" href="/quanly/edit-tags.php?taxonomy=category">«</a> <a class="prev-page disabled" title="Go to the previous page" href="/quanly/edit-tags.php?taxonomy=category&amp;paged=1">‹</a> <span class="paging-input">
                                            <input class="current-page" title="Current page" type="text" name="paged" value="1"
                                                size="1" />
                                            of <span class="total-pages">4</span></span> <a class="next-page" title="Go to the next page"
                                                href="/quanly/edit-tags.php?taxonomy=category&amp;paged=2">›</a> <a class="last-page" title="Go to the last page" href="/quanly/edit-tags.php?taxonomy=category&amp;paged=4">»</a></span>--%>
                                </div>
                                <br class="clear">
                            </div>
                            <table class="wp-list-table widefat fixed tags" cellspacing="0">
                                <thead>
                                    <tr>
                                        <th scope="col" id="cb" class="manage-column column-cb check-column" style="">
                                            <input type="checkbox" id="selectall" />
                                        </th>
                                        <th scope="col" id="name" class="manage-column column-name sortable desc" style="">
                                            <a href="#"><span>Name</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" id="description" class="manage-column column-description sortable desc"
                                            style="">
                                            <a href="#"><span>Description</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" id="slug" class="manage-column column-slug sortable desc" style="">
                                            <a href="#"><span>Slug</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" id="posts" class="manage-column column-posts num sortable desc" style="">
                                            <a href="#"><span>Posts</span><span class="sorting-indicator"></span></a>
                                        </th>
                                    </tr>
                                </thead>
                                <tfoot>
                                    <tr>
                                        <th scope="col" class="manage-column column-cb check-column" style="">
                                            <input type="checkbox" id="selectall2" />
                                        </th>
                                        <th scope="col" class="manage-column column-name sortable desc" style="">
                                            <a href="#"><span>Name</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" class="manage-column column-description sortable desc" style="">
                                            <a href="#"><span>Description</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" class="manage-column column-slug sortable desc" style="">
                                            <a href="#"><span>Slug</span><span class="sorting-indicator"></span></a>
                                        </th>
                                        <th scope="col" class="manage-column column-posts num sortable desc" style="">
                                            <a href="#"><span>Posts</span><span class="sorting-indicator"></span></a>
                                        </th>
                                    </tr>
                                </tfoot>
                                <tbody id="the-list" class="list:tag">
                                    <asp:Repeater ID="rpt" runat="server">
                                        <ItemTemplate>
                                            <tr id="tag-<%#Eval("Id") %>">
                                                <th scope="row" class="check-column">
                                                    <input type="checkbox" name="delete_tags" value="<%#Eval("Id") %>">
                                                </th>
                                                <td class="name column-name">
                                                    <strong><a class="row-title" href="/" title="Edit “<%#Eval("Name") %>”">
                                                        <%#Eval("Name") %></a></strong><br>
                                                    <div class="row-actions">
                                                        <span class="edit"><a href="/Admin/Modules/Categories/CategoryEdit.aspx?Id=<%#Eval("Id") %>">
                                                            Edit</a> | </span>
                                                        <%--<span class="inline hide-if-no-js"><a href="#<%#Eval("Id") %>" class="editinline">Quick&nbsp;Edit</a> | </span>--%>
                                                        <span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">Delete</a></span>
                                                        <%--<span class="view"><a href="/">View</a></span>--%>
                                                    </div>
                                                </td>
                                                <td class="description column-description">
                                                    <%#Eval("Description") %>
                                                </td>
                                                <td class="slug column-slug">
                                                    /category/<%#Eval("Slug") %>.html
                                                </td>
                                                <td class="posts column-posts">
                                                    <a href="/">
                                                        <%#Eval("Count") %></a>
                                                </td>
                                            </tr>
                                        </ItemTemplate>
                                        <AlternatingItemTemplate>
                                            <tr id="tag-<%#Eval("Id") %>" class="alternate">
                                                <th scope="row" class="check-column">
                                                    <input type="checkbox" name="delete_tags" value="<%#Eval("Id") %>" />
                                                </th>
                                                <td class="name column-name">
                                                    <strong><a class="row-title" href="/" title="Edit “<%#Eval("Name") %>”">
                                                        <%#Eval("Name") %></a></strong><br>
                                                    <div class="row-actions">
                                                        <span class="edit"><a href="/Admin/Modules/Categories/CategoryEdit.aspx?Id=<%#Eval("Id") %>">
                                                            Edit</a> | </span>
                                                        <%--<span class="inline hide-if-no-js"><a href="#<%#Eval("Id") %>" class="editinline">Quick&nbsp;Edit</a> | </span>--%>
                                                        <span class="delete"><a class="delete-tag" href="#<%#Eval("Id") %>">Delete</a> </span>
                                                        <%--<span class="view"><a href="/">View</a></span>--%>
                                                    </div>
                                                </td>
                                                <td class="description column-description">
                                                    <%#Eval("Description") %>
                                                </td>
                                                <td class="slug column-slug">
                                                    /category/<%#Eval("Slug") %>.html
                                                </td>
                                                <td class="posts column-posts">
                                                    <a href="/">
                                                        <%#Eval("Count") %></a>
                                                </td>
                                            </tr>
                                        </AlternatingItemTemplate>
                                    </asp:Repeater>
                                </tbody>
                            </table>
                            <div class="tablenav bottom">
                                <div class="alignleft actions">
                                    <select name="action2">
                                        <option value="-1" selected="selected">Bulk Actions</option>
                                        <option value="delete">Delete</option>
                                    </select>
                                    <input type="button" name="" id="doaction2" class="button-secondary action" value="Apply" />
                                </div>
                                <div class="tablenav-pages">
                                    <avg:SmartPager ID="smartPager1" runat="server" Visible="false" />
                                </div>
                                <br class="clear" />
                            </div>
                            <br class="clear" />
                        </div>
                        <div class="form-wrap">
                            <p>
                                <strong>Note:</strong><br>
                                Deleting a category does not delete the posts in that category. Instead, posts that
                                were only assigned to the deleted category are set to the category <strong>Tin Tức</strong>.
                            </p>
                            <p>
                                Categories can be selectively converted to tags using the <a href="import.php">category
                                    to tag converter</a>.
                            </p>
                        </div>
                    </div>
                </div>
                <!-- /col-right -->
                <div id="col-left">
                    <div class="col-wrap">
                        <div class="form-wrap">
                            <h3>
                                Add New Category</h3>
                            <div class="form-field form-required">
                                <label for="tag-name">
                                    Name</label>
                                <input name="tag-name" id="tag-name" type="text" value="" size="40" aria-required="true">
                                <p>
                                    The name is how it appears on your site.
                                </p>
                            </div>
                            <div class="form-field">
                                <label for="tag-slug">
                                    Slug</label>
                                <input name="slug" id="tag-slug" type="text" value="" size="40">
                                <p>
                                    The “slug” is the URL-friendly version of the name. It is usually all lowercase
                                    and contains only letters, numbers, and hyphens.
                                </p>
                            </div>
                            <div class="form-field">
                                <label for="parent">
                                    Parent</label>
                                <asp:DropDownList ID="ddlparent" runat="server" ClientIDMode="Static" AutoPostBack="false"
                                    AppendDataBoundItems="true">
                                    <asp:ListItem Value="-1">None</asp:ListItem>
                                </asp:DropDownList>
                                <p>
                                    Categories, unlike tags, can have a hierarchy. You might have a Jazz category, and
                                    under that have children categories for Bebop and Big Band. Totally optional.
                                </p>
                            </div>
                            <div class="form-field" id='form-field1'>
                                <label for="tag-description">
                                    Description</label>
                                <textarea name="description" id="tag-description" rows="5" cols="40"></textarea>
                                <p>
                                    The description is not prominent by default; however, some themes may show it.
                                </p>
                            </div>
                            <p class="submit">
                                <input type="button" id="addtags" class="button" value="Add New Category">
                            </p>
                        </div>
                    </div>
                </div>
                <!-- /col-left -->
                <br class="clear" />
            </div>
            <!-- /col-container -->
        </div>
        <script type="text/javascript">
            var myTag = new Tag();
            $("#selectall,#selectall2").change(function () {
                if ($(this).attr("checked") == 'checked') {
                    $("input[name=delete_tags]").attr("checked", "checked");
                }
                else {
                    $("input[name=delete_tags]").removeAttr("checked");
                }
            });
            $("input[name=delete_tags]").change(function () {
                if ($(this).attr("checked") != 'checked') {
                    $("#selectall").removeAttr("checked");
                    $("#selectall2").removeAttr("checked");
                }
                else {
                    if ($("input[name=delete_tags]").length == $("input[name=delete_tags]:checked").length) {
                        $("#selectall").attr("checked", "checked");
                        $("#selectall2").attr("checked", "checked");
                    }
                }
            });

            $("#doaction").click(function () {
                if ($('select[name=action] option:selected').val() == 'delete') {
                    var list = $("input[name=delete_tags]:checked");
                    var str = '';
                    if (confirm('Are you sure to delete')) {
                        $(list).each(function () {
                            var Id = $(this).val();
                            var Id2 = myTag.DeleteTag(Id);
                            if (Id2 == -1) {
                                alert("Error!");
                            }
                            $('#tag-' + Id).remove();
                        });
                    }
                }
            });
            $("#doaction2").click(function () {
                if ($('select[name=action2] option:selected').val() == 'delete') {
                    var list = $("input[name=delete_tags]:checked");
                    var str = '';
                    if (confirm('Are you sure to delete')) {
                        $(list).each(function () {
                            var Id = $(this).val();
                            var Id2 = myTag.DeleteTag(Id);
                            if (Id2 == -1) {
                                alert("Error!");
                            }
                            $('#tag-' + Id).remove();
                        });
                    }
                }
            });
            $("#addtags").click(function () {
                var tag_name = $("#tag-name").val();
                var tag_slug = $("#tag-slug").val();
                var tag_des = $("#tag-description").val();

                var parent = $("#ddlparent").val();

                var taxonomy = $("#hdfTaxonomy").val();
                if (tag_name == '') {
                    alert('Name require!');
                    return false;
                }
                myTag.InsertTag(tag_name, tag_slug, parent, tag_des, taxonomy);
            });
            $(".delete-tag").click(function () {
                if (confirm('Are you sure to delete')) {
                    var Id = $(this).attr("href").replace("#", "");
                    var Id2 = myTag.DeleteTag(Id);
                    if (Id2 == -1) {
                        alert("Error!");
                    }
                    $('#tag-' + Id).remove();
                }
            });

        </script>
        <!-- /wrap -->
    </div>
</asp:Content>
